﻿<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/WebForm/MasterPage.master"
    CodeFile="ManageProgramData.aspx.vb" Inherits="WebForm_ManageProgramData" %>
<%@ Register Namespace="My" TagPrefix="cc1" %>
<%@ Register Assembly="App_Code" Namespace="My" TagPrefix="My" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
<TABLE id="Table2" cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR><TD align=center><TABLE cellSpacing=0 cellPadding=0 width="99%" border=0><TBODY><TR><TD align=left><asp:Label id="Label1" SkinID="section" runat="server" Text="外部選單"></asp:Label><BR /><My:MyGridView id="gvOut" runat="server" meta:resourcekey="gv" SkinID="pager" AllowPaging="True" AllowSorting="True" DataSourceID="gvOut_DS" DataKeyNames="ProgramType,ProgramID,Parent" PageSize="20" OnRowDataBound="gvOut_RowDataBound">
<FooterStyle BackColor="White" BorderWidth="0px"></FooterStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<Columns>
<asp:TemplateField HeaderText="NO" InsertVisible="False"><ItemTemplate>
                                            <%#gvOut.PageIndex * gvOut.PageSize + gvOut.Rows.Count + 1%>
                                        
</ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Text" SortExpression="ProgramName" meta:resourceKey="gvText"><EditItemTemplate>
<asp:TextBox id="txtText" runat="server" Text='<%# Bind("ProgramName") %>' __designer:wfdid="w138" MaxLength="50"></asp:TextBox><asp:RequiredFieldValidator id="rfvText" runat="server" meta:resourcekey="rfvText" ValidationGroup="vUpdate" __designer:wfdid="w157" ControlToValidate="txtText" Display="None" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
                <asp:Label ID="lblText" runat="server" Text='<%# Eval("ProgramName") %>'></asp:Label>
            
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="MenuName" SortExpression="ImgText" meta:resourceKey="gvMenuName">
<EditItemTemplate>
<asp:DropDownList id="ddlMenuName" runat="server" DataSourceID="sdMenuName" DataValueField="Value" DataTextField="Text" SelectedValue='<%# Bind("Img") %>'></asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
    <asp:Label ID="lblMenuName" runat="server" Text='<%# Eval("ImgText") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>

<asp:TemplateField><EditItemTemplate>
<asp:LinkButton id="linkbUpdate" runat="server" meta:resourcekey="linkbUpdate" ValidationGroup="vUpdate" __designer:wfdid="w160" CommandName="Update" ForeColor="Black"></asp:LinkButton>&nbsp;<asp:LinkButton id="linkbCancel" runat="server" meta:resourcekey="linkbCancel" __designer:wfdid="w161" CommandName="Cancel" ForeColor="Black"></asp:LinkButton> <asp:ValidationSummary id="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False" ValidationGroup="vUpdate" __designer:wfdid="w162"></asp:ValidationSummary> 
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton id="linkbEdit" runat="server" CommandName="Edit" meta:resourcekey="linkbEdit"></asp:LinkButton>
</ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
</Columns>

<PagerSettings Position="Top"></PagerSettings>
</My:MyGridView> <asp:SqlDataSource id="gvOut_DS" runat="server" DeleteCommand="DELETE FROM [FD_PublicProgram] WHERE [ProgramType] = @ProgramType AND [ProgramID] = @ProgramID" SelectCommand="SELECT [ProgramType], [ProgramID], [ProgramName], [Parent], [Img] , b.Text as ImgText FROM [FD_PublicProgram] a Left join FD_CodeMapping b on a.Img=b.value and b.TableName='Menu' and b.ColumnName='Name' where Visible='Y' ORDER BY convert(varchar,ProgramID)" UpdateCommand="UPDATE [FD_PublicProgram] SET [ProgramName] = @ProgramName,[Img] = @Img WHERE [ProgramType] = @ProgramType AND [ProgramID] = @ProgramID" ConnectionString="<%$ ConnectionStrings:connStr %>" InsertCommand="INSERT INTO [FD_PublicProgram] ([ProgramType], [ProgramID], [ProgramName], [Img]) VALUES (@ProgramType, @ProgramID, @ProgramName, @Img)"><DeleteParameters>
<asp:Parameter Name="ProgramType" Type="String"></asp:Parameter>
<asp:Parameter Name="ProgramID" Type="Int32"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ProgramName" Type="String"></asp:Parameter>
<asp:Parameter Name="Img" Type="String"></asp:Parameter>
<asp:Parameter Name="ProgramType" Type="String"></asp:Parameter>
<asp:Parameter Name="ProgramID" Type="Int32"></asp:Parameter>
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ProgramType" Type="String"></asp:Parameter>
<asp:Parameter Name="ProgramID" Type="Int32"></asp:Parameter>
<asp:Parameter Name="ProgramName" Type="String"></asp:Parameter>
<asp:Parameter Name="Img" Type="String"></asp:Parameter>
</InsertParameters>
</asp:SqlDataSource>&nbsp; </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</ContentTemplate>
        </asp:UpdatePanel> 
    <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
        <contenttemplate>
<TABLE id="table1" cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR><TD align=center><TABLE cellSpacing=0 cellPadding=0 width="99%" border=0><TBODY><TR><TD align=left><asp:Label id="Label2" SkinID="section" runat="server" Text="內部選單"></asp:Label><BR /><My:MyGridView id="gv" runat="server" meta:resourcekey="gv" SkinID="pager" AllowPaging="True" AllowSorting="True" DataSourceID="gv_DS" DataKeyNames="ProgramType,ProgramID,Parent" PageSize="20" OnRowDataBound="gv_RowDataBound">
<FooterStyle BackColor="White" BorderWidth="0px"></FooterStyle>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<Columns>
<asp:TemplateField HeaderText="NO" InsertVisible="False"><ItemTemplate>
                                            <%#gv.PageIndex * gv.PageSize + gv.Rows.Count + 1%>
                                        
</ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Text" SortExpression="ProgramName" meta:resourceKey="gvText"><EditItemTemplate>
<asp:TextBox id="txtText" runat="server" Text='<%# Bind("ProgramName") %>' __designer:wfdid="w138" MaxLength="50"></asp:TextBox><asp:RequiredFieldValidator id="rfvText" runat="server" meta:resourcekey="rfvText" ValidationGroup="vUpdate" __designer:wfdid="w157" ControlToValidate="txtText" Display="None" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
                <asp:Label ID="lblText" runat="server" Text='<%# Eval("ProgramName") %>'></asp:Label>
            
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="MenuName" SortExpression="ImgText" meta:resourceKey="gvMenuName">
<EditItemTemplate>
<asp:DropDownList id="ddlMenuName" runat="server" __designer:wfdid="w1" DataSourceID="sdMenuName" DataValueField="Value" DataTextField="Text" SelectedValue='<%# Bind("Img") %>'></asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
    <asp:Label ID="lblMenuName" runat="server" Text='<%# Eval("ImgText") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>

<asp:TemplateField><EditItemTemplate>
<asp:LinkButton id="linkbUpdate" runat="server" meta:resourcekey="linkbUpdate" ValidationGroup="vUpdate" __designer:wfdid="w160" CommandName="Update" ForeColor="Black"></asp:LinkButton>&nbsp;<asp:LinkButton id="linkbCancel" runat="server" meta:resourcekey="linkbCancel" __designer:wfdid="w161" CommandName="Cancel" ForeColor="Black"></asp:LinkButton> <asp:ValidationSummary id="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False" ValidationGroup="vUpdate" __designer:wfdid="w162"></asp:ValidationSummary> 
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton id="linkbEdit" runat="server" CommandName="Edit" meta:resourcekey="linkbEdit"></asp:LinkButton>
</ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
</Columns>

<PagerSettings Position="Top"></PagerSettings>
</My:MyGridView> <asp:SqlDataSource id="gv_DS" runat="server" DeleteCommand="DELETE FROM [FD_Program] WHERE [ProgramType] = @ProgramType AND [ProgramID] = @ProgramID" SelectCommand="SELECT [ProgramType], [ProgramID], [ProgramName], [Parent], [Img] , b.Text as ImgText FROM [FD_Program] a Left join FD_CodeMapping b on a.Img=b.value and b.TableName='Menu' and b.ColumnName='Name' where Visible='Y' ORDER BY convert(varchar,ProgramID)" UpdateCommand="UPDATE [FD_Program] SET [ProgramName] = @ProgramName,[Img] = @Img WHERE [ProgramType] = @ProgramType AND [ProgramID] = @ProgramID" ConnectionString="<%$ ConnectionStrings:connStr %>" InsertCommand="INSERT INTO [FD_Program] ([ProgramType], [ProgramID], [ProgramName], [Img]) VALUES (@ProgramType, @ProgramID, @ProgramName, @Img)"><DeleteParameters>
<asp:Parameter Name="ProgramType" Type="String"></asp:Parameter>
<asp:Parameter Name="ProgramID" Type="Int32"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ProgramName" Type="String"></asp:Parameter>
<asp:Parameter Name="Img" Type="String"></asp:Parameter>
<asp:Parameter Name="ProgramType" Type="String"></asp:Parameter>
<asp:Parameter Name="ProgramID" Type="Int32"></asp:Parameter>
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ProgramType" Type="String"></asp:Parameter>
<asp:Parameter Name="Img" Type="String"></asp:Parameter>
<asp:Parameter Name="ProgramID" Type="Int32"></asp:Parameter>
<asp:Parameter Name="ProgramName" Type="String"></asp:Parameter>
</InsertParameters>
</asp:SqlDataSource>&nbsp; </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</contenttemplate>
    </asp:UpdatePanel>
    <asp:SqlDataSource ID="sdMenuName" runat="server" ConnectionString="<%$ ConnectionStrings:connStr %>"
        SelectCommand="SELECT [Text], [Value] FROM [FD_CodeMapping] WHERE (([TableName] = @TableName) AND ([ColumnName] = @ColumnName)) ORDER BY [Sequence]">
        <SelectParameters>
            <asp:Parameter DefaultValue="Menu" Name="TableName" Type="String" />
            <asp:Parameter DefaultValue="Name" Name="ColumnName" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
